<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <div onclick="alert(1)">
    <button id="btn">获取event事件对象</button>
  </div>
  <script>
    var btn = document.getElementById('btn');
    btn.onclick = function (e) {
      var event = e || window.event;    // 获取事件对象的兼容处理
      alert(2)
    };
  </script>
</body>
</html>